﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Copad.BusinessCard.Model
{
    public class Card
    {
        public CardInfo Summary { get; set; }
        public List<CardAddress> Address { get; private set; }
        public List<CardCompany> Company { get; private set; }
        public List<CardPhoneNumber> Number { get; private set; }
        public List<CardRemark> Remark { get; private set; }
        public List<CardWebsite> Website { get; private set; }
        public List<CardIM> IM { get; private set; }
        public List<CardEmail> Email { get; private set; }
        public List<CardCategory> Category { get; private set; }
        public Favorite FavoriteInfo { get; set; }
        public string CellNumbers { get; private set; }
        public string WorkNumbers { get; private set; }
        public List<string> QQ { get; private set; }

        public Card()
        {
            Address = new List<CardAddress>(2);
            Number = new List<CardPhoneNumber>(4);
            Remark = new List<CardRemark>(2);
            Company = new List<CardCompany>(2);
            Website = new List<CardWebsite>(2);
            IM = new List<CardIM>(2);
            Email = new List<CardEmail>(2);
            Category = new List<CardCategory>(2);
        }
        
        public void InitNumbers()
        {
            CellNumbers = "";
            WorkNumbers = "";
            this.Number.ForEach(x =>
            {
                if (x.Type == "CELL")
                {
                    CellNumbers += x.Number + " ";
                }
                else if (x.Type == "WORK")
                {
                    WorkNumbers += x.Number + " ";
                }
            });

            QQ = new List<string>();
            this.IM.ForEach(x =>
            {
                if (x.Type == "QQ")
                {
                    QQ.Add(x.Account);
                }
            });
        }
    }
}
